package com.leen.news.controller;

import com.leen.common.vo.ResponseVO;
import com.leen.common.vo.ResultVO;
import com.leen.news.dto.YxSystemGroupDataDTO;
import com.leen.news.entity.YxSystemGroupData;
import com.leen.news.service.YxSystemGroupDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/news/ysgroup")
@Api(tags = "组合数据详情")
public class YxSystemGroupDataController {

    @Autowired
    private YxSystemGroupDataService yxSystemGroupDataService;

    @GetMapping(value = "/data")
    @ApiOperation(value = "分页查询")
    public ResultVO<ResponseVO> search(YxSystemGroupDataDTO yxSystemGroupDataDTO){
        ResponseVO search = this.yxSystemGroupDataService.search(yxSystemGroupDataDTO);
        return ResultVO.success(search);
    }


    @PostMapping(value = "/add")
    @ApiOperation(value = "添加数据")
    public ResultVO<String> insert(@RequestBody @Valid YxSystemGroupData yxSystemGroupData){
        return this.yxSystemGroupDataService.insert(yxSystemGroupData);
    }


    @PostMapping(value = "/update")
    @ApiOperation(value = "修改数据")
    public ResultVO<String> update(@RequestBody @Valid YxSystemGroupData yxSystemGroupData){
        return this.yxSystemGroupDataService.updateById(yxSystemGroupData);
    }
    @PostMapping(value = "/delete")
    @ApiOperation(value = "删除数据")
    public ResultVO<String> delete(@RequestBody @Valid YxSystemGroupData yxSystemGroupData){
        yxSystemGroupData.setIsDel(true);
        return this.yxSystemGroupDataService.updateById(yxSystemGroupData);
    }
}
